<?php

namespace app\common\model;

use app\common\RootModel;

class MemberInviteModel extends RootModel
{
    protected $pk = 'id';
    protected $table = 'sys_member_invite';

    /**
     * 奖励类型
     * @var array
     */
    public static $typeLabel = [1 => '第一阶段奖励', 2 => '第二阶段奖励', 3 => '第三阶段奖励'];

    /**
     * 奖励金额
     * @return int
     */
    protected function mbiAmount()
    {
        return $this->hasOne(MoneyRecordModel::class, 'id', 'record_id')->field(['id', 'amount', 'currency']);
    }

    /**
     * 最后登录时间
     */
    protected function mbLogin()
    {
        return $this->hasOne(MemberLoginModel::class, 'member_id', 'member_id')
            ->order(['id' => 'desc'])->field(['member_id', 'create_time']);
    }
}